package com.sk.bilibili.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sk.bilibili.bean.Danmu;
import com.sk.bilibili.dto.FakeDanmu;
import com.sk.bilibili.other.R;
import com.sk.bilibili.service.DanmuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author 邵康
 * @date 2021/11/26 19:24
 */
@Api(tags = "弹幕管理")
@CrossOrigin
@RestController
@RequestMapping("/danmu")
public class DanmuController {

    @Autowired
    private DanmuService danmuService;

    @ApiOperation("添加弹幕   名字奇怪是因为  弹幕播放器要求的")
    @PostMapping("/v3")
    public R<Void> add() {
        return R.success();
    }

    @ApiOperation("获取   名字奇怪是因为  弹幕播放器要求的")
    @GetMapping("/v3")
    public R<Object[][]> getAll(@RequestParam("id") Integer videoId) {
        return danmuService.getAll(videoId);
    }

    @ApiOperation("添加弹幕 安卓版特供")
    @PostMapping("/add")
    public R<Void> add(@RequestBody Danmu danmu) {
        return danmuService.add(danmu);
    }

    @ApiOperation("获取   安卓版特供")
    @GetMapping("/getAll")
    public R<List<Danmu>> getAllDanmu(Integer videoId) {
        return danmuService.getAllDanmu(videoId);
    }

    @ApiOperation("deleteRes")
    @GetMapping("/delete")
    public R<Void> delete(Integer id) {
        return danmuService.delete(id);
    }

    @ApiOperation("update")
    @PostMapping("/update")
    public R<Void> update(@RequestBody Danmu danmu) {
        return danmuService.update(danmu);
    }

    @ApiOperation("pageSearch")
    @GetMapping("/page")
    public R<IPage<Danmu>> page(@RequestParam(defaultValue = "1") Integer page,
                                @RequestParam(defaultValue = "10") Integer size) {
        return danmuService.page(page, size);
    }


}
